package com.abc.controller;

import com.abc.bean.Doctor;
import com.abc.service.DoctorService;
import com.abc.service.KcyhService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bc
 * @Date: 2024-11-17 12:44
 * @Description:
 */
@RestController()
@RequestMapping("/kcyh")
public class KcyhController {

    @Autowired
    private KcyhService kcyhService;

    @RequestMapping("/selectKcyhByPatientId")
    public List<Map<String,Object>> selectKcyhByPatientId(String patientId) {
        return kcyhService.selectKcyhByPatientId(patientId);
    }
    @RequestMapping("/insertKcyh")
    public String insertKcyh(@RequestParam Map<String,Object> map) {
        System.out.println(">>>"+map);
        if(kcyhService.selectKcyhByPatientId(map.get("hid")+"").size()==0){
            System.out.println("insert");
            kcyhService.insertKcyh(map);
        }else{
            System.out.println("update");
            kcyhService.updateKcyh(map);
        }
        return "";
    }
    @RequestMapping("/updateKcyh")
    public int updateKcyh(Map<String,Object> map) {
        return kcyhService.updateKcyh(map);
    }
}
